package com.wudi.estate.service.impl.ownermanagement;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wudi.estate.bean.ownermanagement.Pet;
import com.wudi.estate.mapper.ownermanagement.PetMapper;
import com.wudi.estate.service.ownermanagement.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class PetServiceImpl implements PetService {
    @Autowired
    private PetMapper petMapper;
    @Override
    public List<Pet> selectAll() throws Exception {
        return petMapper.selectAll();
    }

    @Override
    public PageInfo<Map<String, Object>> selectAllTwo(Integer startPage,Integer size) throws Exception {
        PageHelper.startPage(startPage,size);
        List<Map<String,Object>> pets=petMapper.selectAllTwo();
        PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(pets);
        return pageInfo;
    }

    @Override
    public Pet selectById(Pet p) throws Exception {
        return petMapper.selectById(p);
    }

    @Override
    public void updateById(Pet p) throws Exception {
        petMapper.updateById(p);
    }

    @Override
    public void updateStateById(Pet p) throws Exception {
        petMapper.updateStateById(p);
    }

    @Override
    public void insert(Pet p) throws Exception {
        petMapper.insert(p);
    }

    @Override
    public List<Pet> selectByName(String name) throws Exception {
        return petMapper.selectByName(name);
    }
}
